package main.com.hushengjin.producer;

import main.com.hushengjin.factory.AbstractFactory;
import main.com.hushengjin.factory.ColorFactory;
import main.com.hushengjin.factory.ShapeFactory;

public class FactoryProducer {
    public static AbstractFactory getFactory(String choice) {
        if (choice == null || choice.trim().length() < 1) throw new IllegalArgumentException("参数不合法：" + choice);
        choice = choice.toUpperCase();
        AbstractFactory factory;
        switch (choice) {
            case "SHAPE":
                factory = new ShapeFactory();
                break;
            case "COLOR":
                factory = new ColorFactory();
                break;
            default:
                throw new IllegalArgumentException("参数不合法：" + choice);
        }
        return factory;
    }
}
